import React from 'react'
import { Switch } from 'react-router-dom'
import {HashRouter,Route,Redirect} from 'react-router-dom'
import Login from '../views/Login/Login'
import Details from '../views/news/Detail'
import News from '../views/news/News'
import NewsSandBox from '../views/NewSandbox/NewsSandBox'
function IndexRouter() {
    return (
        <HashRouter>
            <Switch>
                <Route  path='/login' component={Login}/>
                <Route path="/news" component={News} />
                <Route path="/detail/:id" component={Details} />
                {/* <Route  path='/' component={NewsSandBox}/> */}
                <Route path='/' render={()=>{ 
                   return localStorage.getItem("token")?<NewsSandBox/>:<Redirect to="/login"/>
                }}/>
                
            </Switch>
        </HashRouter>
    )
}

export default IndexRouter
